home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
DOpus Plus
/
DOpus Plus.iso
/
Tutorial
/
C Guide
/
Time_module
/
ClockConfig.c
< prev
next >
Wrap
C/C++ Source or Header
|
1998-09-20
|
3KB
|
89 lines
/* ClockConfig.c
*/
#include "includes/Clock.h"
#include <libraries/iffparse.h>
#define ID_PROG MAKE_ID('D','O','C','C')
#define ID_NUMB MAKE_ID('N','U','M','M')
#define ID_FONT MAKE_ID('F','O','N','T')
#define ID_PICT MAKE_ID('B','G','P','C')
BOOL WriteConfig( ClockData *cd )
{
APTR iffhandle;
if( (iffhandle = IFFOpen(CLOCKCONFIG, IFF_WRITE, ID_PROG)) )
{
IFFPushChunk( iffhandle, ID_NUMB );
IFFWriteChunkBytes( iffhandle, &cd->ibox, sizeof(WORD) * 2 );
IFFWriteChunkBytes( iffhandle, &cd->flags, sizeof(ULONG) );
IFFWriteChunkBytes( iffhandle, &cd->txtattr.ta_YSize, sizeof(UWORD) );
IFFWriteChunkBytes( iffhandle, &cd->txtattr.ta_Style, sizeof(UBYTE) );
IFFWriteChunkBytes( iffhandle, &cd->itext[0].FrontPen, sizeof(UBYTE) );
IFFWriteChunkBytes( iffhandle, &cd->itext[0].BackPen, sizeof(UBYTE) );
IFFWriteChunkBytes( iffhandle, &cd->itext[0].DrawMode, sizeof(UBYTE) );
IFFWriteChunkBytes( iffhandle, cd->woday, strlen(cd->woday) );
IFFPopChunk( iffhandle );
if( strlen(cd->fontname) > 5 )
{
IFFWriteChunk(iffhandle, cd->fontname, ID_FONT, strlen(cd->fontname)+1);
}
if( cd->picture[0] )
{
IFFWriteChunk(iffhandle, cd->picture, ID_PICT, strlen(cd->picture)+1);
}
IFFClose( iffhandle );
return 0;
};
return 1;
}
BOOL ReadConfig( ClockData *cd )
{
APTR iffhandle;
ULONG nextchunk;
if( (iffhandle = IFFOpen(CLOCKCONFIG, IFF_READ, ID_PROG)) )
{
while( (nextchunk = IFFNextChunk(iffhandle, 0)) )
{
switch( nextchunk )
{
case ID_FONT: IFFReadChunkBytes( iffhandle, cd->fontname, 32 );
break;
case ID_PICT: IFFReadChunkBytes( iffhandle, cd->picture, 256 );
break;
case ID_NUMB: IFFReadChunkBytes(iffhandle, &cd->ibox, sizeof(WORD) * 2 );
IFFReadChunkBytes(iffhandle, &cd->flags, sizeof(ULONG) );
IFFReadChunkBytes(iffhandle, &cd->txtattr.ta_YSize, sizeof(UWORD) );
IFFReadChunkBytes(iffhandle, &cd->txtattr.ta_Style, sizeof(UBYTE) );
IFFReadChunkBytes(iffhandle, &cd->itext[0].FrontPen, sizeof(UBYTE) );
IFFReadChunkBytes(iffhandle, &cd->itext[0].BackPen, sizeof(UBYTE) );
IFFReadChunkBytes(iffhandle, &cd->itext[0].DrawMode, sizeof(UBYTE) );
IFFReadChunkBytes(iffhandle, cd->woday, 16 );
break;
};
};
IFFClose( iffhandle );
return 0;
};
return 1;
}